package com.gz.furnitures.service.impl;

import com.gz.furnitures.dao.impl.MemberDaoImpl;
import com.gz.furnitures.entity.Member;
import com.gz.furnitures.service.MemberService;

public class MemberServiceImpl implements MemberService {
    private MemberDaoImpl memberDao = new MemberDaoImpl();
    @Override
    public boolean registerMember(Member member) {
        return memberDao.insertMember(member)>0;
    }


    @Override
    public boolean isExistsUsername(String username) {
        //小技巧
        //如果想看一个方法ctrl+b可能会跳转到它的接口
        //而用ctrl+alt+b会跳转到它的实现类
        /**
         * 判断用户名是否存在
         */
        Member member = memberDao.queryMemberByName(username);
        return member != null;
    }

    @Override
    public Member login(Member member) {
        return memberDao.queryMemberByNameAndPassword(member.getUsername(), member.getPassword());
    }
}
